<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path;
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<title>${config.appName}插班生报名</title>
<link rel="stylesheet" href="<%=basePath %>/style/weuix.min.css"/>
<script src="<%=basePath %>/js/zepto.min.js"></script>
<script src="<%=basePath %>/js/picker-city.js"></script>
<script src="<%=basePath %>/js/picker.js"></script>
<script src="<%=basePath %>/js/select.js"></script>
<body ontouchstart>
  <div id="mainBox">
	<form name="formBaomingForm" id="formBaomingForm" action="submit" method="post">
		<div class="weui_cells weui_cells_form" style="margin-top:-8px;" id="sj">
			<img style="width:100%;" src="<%=basePath %>/images/chabansheng@3x.png">
				<div class="weui_cells weui_cells_form" style="margin-top:-8px;">
			   	   <input type="hidden" name="signUpType" value="${signUpType }"/>
			   	   <input type="hidden" name="id"/>
			   	   <div class="weui_cell f-red" style="padding: 10px;">说明：所有项目必填，如无相关资料，请填写“无”。</div>
			       <div class="weui_cell lblue">
	                    <div class="weui_cell_bd weui_cell_primary">
	                        <p class="f-blue bold">学生基本资料</p>
	                    </div>
	               </div>
			       <div class="weui_cell" style="padding-top:15px;">
			          <div class="weui_cell_hd"><label class="weui_label">学生姓名</label></div>
			          <div class="weui_cell_bd weui_cell_primary">
			              <input class="weui_input" type="text" name="studentName" placeholder="请输入学生姓名">
			          </div>
			       </div>
			       
			       <div class="weui_cell">
			          <div class="weui_cell_hd"><label class="weui_label">学生性别</label></div>
			          <div class="weui_cell_bd weui_cell_primary">
			              <input class="weui_input" type="text" name="studentSex" id="studentSex" placeholder="请选择">
			          </div>
			      </div>
				  
				  <div class="weui_cell">
			          <div class="weui_cell_hd"><label for="" class="weui_label">出生日期</label></div>
			          <div class="weui_cell_bd weui_cell_primary">
			              <input class="weui_input" id="studentBirthday" name="studentBirthday" type="date" value="" placeholder="请选择">
			          </div>
			      </div>
			      <div class="weui_cell">
	                <div class="weui_cell_hd">
	                	<label class="weui_label">证件类型</label>
	                </div>
	                <div class="weui_cell_bd weui_cell_primary">
			              <input class="weui_input" type="text" name="studentIdType" id="studentIdType" placeholder="请选择">
			        </div>
	              </div>
			      <div class="weui_cell">
			      	  <div class="weui_cell_hd"><label for="" class="weui_label">证件号</label></div>
					  <div class="weui_cell_bd weui_cell_primary">
						 <input class="weui_input" type="text" name="studentIdNo" placeholder="请输入学生的证件号" />
					  </div>
				  </div>
				  <div class="weui_cell">
					  <div class="weui_cell_hd"><label for="" class="weui_label">报读年级</label></div>
					  <div class="weui_cell_bd weui_cell_primary">
			              <input class="weui_input" type="text" name="signGrade" id="signGrade" placeholder="请选择">
			          </div>
				  </div>
				  <div class="weui_cell">
			          <div class="weui_cell_hd"><label class="weui_label">健康状况</label></div>
			          <div class="weui_cell_bd weui_cell_primary">
			              <input class="weui_input" type="text" name="healthy" id="healthy" placeholder="请输入学生健康状况">
			          </div>
			       </div>
				  <div class="weui_cell">
			          <div class="weui_cell_hd"><label class="weui_label">原就读学校</label></div>
			          <div class="weui_cell_bd weui_cell_primary">
			              <input class="weui_input" type="text" name="baseSchool" placeholder="需注明省市区">
			          </div>
			      </div>
			      <div class="weui_cell">
			          <div class="weui_cell_hd"><label class="weui_label">民族</label></div>
			          <div class="weui_cell_bd weui_cell_primary">
			              <input class="weui_input" type="text" id="nation" name="nation" placeholder="请选择">
			          </div>
			      </div>
			      <div class="weui_cell">
			          <div class="weui_cell_hd"><label class="weui_label">籍贯</label></div>
			          <div class="weui_cell_bd weui_cell_primary">
			              <input class="weui_input" type="text" id="nativePlace" name="nativePlace" placeholder="例：广东佛山">
			          </div>
			      </div>
			      <div class="weui_cell">
			          <div class="weui_cell_hd"><label class="weui_label">户籍所在地</label></div>
			          <div class="weui_cell_bd weui_cell_primary">
			              <input class="weui_input" type="text" id="houseSSQ" name="houseSSQ" placeholder="请选择">
			          </div>
			      </div>
			      <div class="weui_cell">
			          <div class="weui_cell_hd"><label class="weui_label">户籍所在镇街</label></div>
			          <div class="weui_cell_bd weui_cell_primary">
			              <input class="weui_input" type="text" id="houseAddr" name="houseAddr" placeholder="请输入户籍所在镇街">
			          </div>
			      </div>
			      <div class="weui_cell">
			          <div class="weui_cell_hd"><label class="weui_label">家庭地址</label></div>
			          <div class="weui_cell_bd weui_cell_primary">
			              <input class="weui_input" type="text" id="familyAddr" name="familyAddr" placeholder="请输入家庭地址">
			          </div>
			      </div>
			      <div class="weui_cell lblue">
	                    <div class="weui_cell_bd weui_cell_primary">
	                        <p class="f-blue bold">家庭主要成员资料</p>
	                    </div>
	               </div>
			      <div class="weui_cell">
			          <div class="weui_cell_hd"><label class="weui_label">父亲姓名</label></div>
			          <div class="weui_cell_bd weui_cell_primary">
			              <input class="weui_input" type="text" name="fatherName" placeholder="请输入父亲姓名">
			          </div>
			      </div>
			      <div class="weui_cell">
			          <div class="weui_cell_hd"><label class="weui_label">父亲电话</label></div>
			          <div class="weui_cell_bd weui_cell_primary">
			              <input class="weui_input" type="number" pattern="[0-9]*" name="fatherPhone" placeholder="请输入父亲电话">
			          </div>
			      </div>
			      <div class="weui_cell">
			          <div class="weui_cell_hd"><label class="weui_label">父亲单位</label></div>
			          <div class="weui_cell_bd weui_cell_primary">
			              <input class="weui_input" type="text" name="fatherCompany" placeholder="请输入父亲单位">
			          </div>
			      </div>
			      <div class="weui_cell">
			          <div class="weui_cell_hd"><label class="weui_label">母亲姓名</label></div>
			          <div class="weui_cell_bd weui_cell_primary">
			              <input class="weui_input" type="text" name="motherName" placeholder="请输入母亲姓名">
			          </div>
			      </div>
			      <div class="weui_cell">
			          <div class="weui_cell_hd"><label class="weui_label">母亲电话</label></div>
			          <div class="weui_cell_bd weui_cell_primary">
			              <input class="weui_input" type="number" pattern="[0-9]*" name="motherPhone" placeholder="请输入母亲电话">
			          </div>
			      </div>
			      <div class="weui_cell">
			          <div class="weui_cell_hd"><label class="weui_label">母亲单位</label></div>
			          <div class="weui_cell_bd weui_cell_primary">
			              <input class="weui_input" type="text" name="motherCompany" placeholder="请输入母亲单位">
			          </div>
			      </div>
			      <div class="weui_cell lblue">
	                    <div class="weui_cell_bd weui_cell_primary">
	                        <p class="f-blue bold">就读方式</p>
	                    </div>
	               </div>
	               <div class="weui_cell">
			          <div class="weui_cell_hd"><label class="weui_label">就读方式</label></div>
			          <div class="weui_cell_bd weui_cell_primary">
			              <input class="weui_input" type="text" id="schoolStudyType" name="schoolStudyType" placeholder="请选择就读方式">
			          </div>
			       </div>
			       <div class="weui_cell">
			          <div class="weui_cell_hd"><label class="weui_label" style="width:150px;">是否参加开放日</label></div>
			          <div class="weui_cell_bd weui_cell_primary">
			              <input class="weui_input" type="text" id="isJoinOpenday" name="isJoinOpenday" placeholder="请选择">
			          </div>
			       </div>
			       <p style="padding: 0px 15px;color: #d97e2e;font-size: 0.9rem;">学校开放日时间：2019年12月21日上午9:00，学校将举行校园开放日活动（面向转学生及家长），欢迎家长和孩子莅临参加。</p>
			      <div class="weui_btn_area">
			        <a id="formSubmitBtn" href="javascript:formBaomingTj()" class="weui_btn weui_btn_primary">提交报名</a>
			      </div>
		  	 </div>
		  </form>
		  <div class="weui_tabbar hide" style="padding: 5px;">
				<div class="weui_cells_tips">
					<span style="color:red" id="result"></span>请再次核查信息，如果有误请点击【<a href="javascript:baomingUpdate()">修改</a>】
				</div>
		  </div>
	</div>		
</body>
<script>
	$(function() {
		if(!/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) {
     		$("#mainBox").attr("style","width:450px;margin: 0 auto;")
     	}
		initGrade();
		$("#studentBirthday").datetimePicker({title:"选择日期",m:1});
		$("#houseSSQ").cityPicker({
	        title: "户籍所在地"
	    });
		$("#schoolStudyType").select({
        	title: "选择就读方式",
        	items: [
	          {
	            title: "走读 (17:30放学)",
	            value: "1",
	          },
	          {
	            title: "晚修后走读 (一年级20：00放学，二、三、四、五年级 20:30放学)",
	            value: "2",
	          },
	          {
	            title: "住宿 (周日19:00上学、周五16:10放学)",
	            value: "3",
	          }
	        ]
        });
		$("#nation").picker({
			title: "请选择民族",
	        autoClose:true,
	        cols: [{textAlign: 'center',
	                values: [
	                 		"汉族", "蒙古族",  "回族", "藏族", "维吾尔族", "苗族",  "彝族", "壮族", "布依族", "朝鲜族",
	                		"满族", "侗族", "瑶族", "白族", "土家族", "哈尼族", "哈萨克族", "傣族", "黎族", "傈僳族",
	                        "佤族", "畲族", "高山族", "拉祜族", "水族", "东乡族", "纳西族", "景颇族", "柯尔克孜族",
	                        "土族", "达斡尔族", "仫佬族", "羌族", "布朗族", "撒拉族", "毛南族", "仡佬族", "锡伯族",
	                        "阿昌族", "普米族", "塔吉克族", "怒族", "乌孜别克族", "俄罗斯族", "鄂温克族", "德昂族",
	                        "保安族", "裕固族", "京族", "塔塔尔族", "独龙族", "鄂伦春族", "赫哲族", "门巴族", "珞巴族",
	                        "基诺族", "亻革家人", "穿青人"
	                    ]
	              }]
		});
		$("#isJoinOpenday").picker({
	        title: "请选择",
	        autoClose:true,
	        cols: [{textAlign: 'center',
	                values: ['参加','不参加']
	              }]
	    });
		$("#studentSex").picker({
	        title: "请选择学生性别",
	        autoClose:true,
	        cols: [{textAlign: 'center',
	                values: ['男孩','女孩']
	              }]
	    });
		$("#studentIdType").picker({
	        title: "请选择证件类型",
	        autoClose:true,
	        cols: [{textAlign: 'center',
	                values: ['居民身份证','香港特区护照/身份证明','澳门特区护照/身份证明','台湾居民来往大陆通行证','境外永久居住证','护照','港澳居民居住证','台湾居民居住证','其他']
	              }]
	    });
		/*$("#healthy").select({
			title: "请选择健康状况",
	        multi: true,
	        split:',',
	        closeText:'确定',
	        items: [
	                {title: "健康",value: "健康"},
	                {title: "多动症",value: "多动症"},
	                {title: "自闭症",value: "自闭症"},
	                {title: "梦游症",value: "梦游症"},
	                {title: "暴力倾向",value: "暴力倾向"},
	                {title: "做过手术",value: "做过手术"},
	                {title: "先天性心脏病",value: "先天性心脏病"},
	                {title: "其它特殊情况",value: "其它特殊情况"}
	               ]
	    });*/
	})
	function initGrade() {
		$.ajax({
			url: "<%=basePath %>/signup/student/middleStudentGrade",
			type: 'GET',
			dataType : "json",
			success: function(data) {
				var d = new Date();
				var grade = [];
				var array = data.gradeName.split(",");
				for(var i in array) {
					grade.push((d.getFullYear()+((d.getMonth()+1)<9 ? 0 : 1))+"年春季"+array[i]+"插班生");
				}
				$("#signGrade").picker({
			        title: "请选择报读年级",
			        autoClose:true,
			        cols: [{textAlign: 'center',
			                values: grade
			              }]
			    });
			},
			error: function(data) {
				$.toptips("异常,请联系管理员");
			}
		});
	}
	function formBaomingTj(){
		if(formBaomingForm.studentName.value.trim()==""){
			$.alert("请输入学生姓名","");
			return false;
		}
		if(formBaomingForm.studentSex.value.trim()==""){
			$.alert('请选择学生性别',"");
			return false;
		}	
		if(formBaomingForm.studentBirthday.value.trim()==""){
			$.alert('请输入生日',"");
			return false;
		}
		var sfxh=formBaomingForm.studentIdNo.value.trim();
		if(sfxh==""){
			$.alert('请输入证件号',"");
			return false;
		}
		var healthy=formBaomingForm.healthy.value.trim();
		if(healthy==""){
			$.alert('请选择健康状况',"");
			return false;
		}
		if(formBaomingForm.signGrade.value.trim()==""){
			$.alert('请选择报读年级',"");
			return false;
		}	
		var fqdh=formBaomingForm.fatherPhone.value.trim();
		var mqdh=formBaomingForm.motherPhone.value.trim();
		if(fqdh=="" && mqdh==""){
			$.alert('父亲电话和母亲电话必须填写一个',"");
			return false;
		}
		if(formBaomingForm.schoolStudyType.value.trim()==""){
			$.alert('请选择就读方式',"");
			return false;
		}
		if(formBaomingForm.isJoinOpenday.value.trim()==""){
			$.alert('请选择是否参加学校开放日',"");
			return false;
		}
		var data = $("#formBaomingForm").serialize();
		var schoolStudyType = $("#schoolStudyType").attr("data-values");
		data = replaceParamVal(data,"schoolStudyType",schoolStudyType);
		$.ajax({
			url: "<%=basePath %>/signup/student/submit",
			type: 'POST',
			dataType : "json",
			data: data,
			success: function(data) {
				if (data.code == "000") {
					$.toast("报名提交成功");
					$("#result").html("报名提交成功");
					$("input[name='id']").val(data.data);
					$(".weui_cells_form").find(".weui_cell .weui_cell_primary")
					.each(function(i,v) {
						$(v).children().attr("disabled",true);
					});
					$(".weui_tabbar").show();
				} else {
					 $.toptips(data.msg);
				}
			},
			error: function(data) {
				$.toptips("提交异常,请联系管理员");
			}
		});
	}
	
	function baomingUpdate() {
		$(".weui_cells_form").find(".weui_cell .weui_cell_primary")
		.each(function(i,v) {
			$(v).children().removeAttr("disabled");
		});
		$(".weui_tabbar").hide();
	}
	function replaceParamVal(oUrl,paramName,replaceWith) {
	    var re=eval('/('+ paramName+'=)([^&]*)/gi');
	    var nUrl = oUrl.replace(re,paramName+'='+replaceWith);
	    return nUrl;
	}
	
</script>
</html>